
package com.shangsi.service.impl;

import com.shangsi.feign.AccountFeignService;
import com.shangsi.feign.OrderFeignService;
import com.shangsi.model.TOrder;
import com.shangsi.service.ShoppingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author dzd
 * @date 2021-12-19
 */
@Service
public class ShoppingServiceImpl implements ShoppingService {

    @Resource
    AccountFeignService accountFeignService;

    @Resource
    OrderFeignService orderFeignService;


    @Override
    public Boolean shopping(Integer userId, Integer amount, Integer count, String remark) {
        TOrder tOrder=new TOrder();
        tOrder.setUserId(userId);
        tOrder.setAmount(amount);
        tOrder.setCount(count);
        tOrder.setRemark(remark);
        orderFeignService.createOrder(tOrder);

        accountFeignService.decrease(amount,userId);
        return true;
    }
}
